/*张欢欢 设备类型页面*/
var totalPage;
var totalCnt;
var branchCompanyData = [];

$(document).ready(function() {
	showLoading();
	$('title', parent.document).html($('title').text());
	setBaseUrl();
	createTableHead("branchCompanyThead", branchCompanyTable, search);
	scrollTableSuspend("scrollBody", "branchCompanyTable", "branchCompanyTable1", "branchCompanyThead", "scrollHeight");
	search();
	setTimeout(hideLoading, 500);
});

function search(){
	$ajax('searchBranchCompany', 'searchBranchCompany', searchBranchCompany);
}
function searchBranchCompany(data) {
	totalPage = data && data.totalPage || 0;
	totalCnt = data && data.totalCnt || 0;
	branchCompanyData = data && data.branchCompanyList || [];
	createTableBody("branchCompanyTbody", branchCompanyTable, branchCompanyData);
	setTimeout(hideLoading, 500);
}
function chkBefore(index, chkFlag){
	var checkbox =document.getElementsByName("chk"); 
	for(var i=0; i<checkbox.length; i++){
		checkbox[i].checked = false; 
	}
	checkbox[index].checked = true; 
	if(chkFlag == "update"){
		update(index);
	}else if(chkFlag == "delete"){
		del();
	}
}
function save() {
	window.parent.skipSecondMenu('chargingStation/branchCompanySave', 'branchCompany', 'chargingStationPage');
}
function update(index) {
	window.parent.detalisSkip('chargingStation/branchCompanyUpdate', index, $("#currentPage").val());
	$("#parentSkipMenu", parent.document).val("equipmentInfoPage");
	$("#detailID", parent.document).val(branchCompanyData[index].branchCompanyName);
}
function confirm(){
	return checkForm("saveForm", branchCompanyTable);
}
function getUrl(){
	return 'deleteBranchCompany';
}
function getData(){
	return {branchCompanyIDList: getCheckDataList(branchCompanyData, "branchCompanyID")};
}
function sure(data){
	var result = data && data.result;
	if (result == "Success") {
		showMessge(messageContent["Delete.Success"]);
	} else if (result == "NotFound") {
		showMessge(messageContent["Delete.NotFound"]);
	} else {
		showMessge(messageContent["Delete.Error"]);
	}
	$ajax('searchBranchCompany', 'searchBranchCompany', searchBranchCompany);
}